<!DOCTYPE html>





<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 3.9.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/favicon.ico?v=7.4.0">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon.ico?v=7.4.0">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon.ico?v=7.4.0">
  <link rel="mask-icon" href="/images/logo.svg?v=7.4.0" color="#222">

<link rel="stylesheet" href="/css/main.css?v=7.4.0">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css?v=4.7.0">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '7.4.0',
    exturl: false,
    sidebar: {"position":"left","display":"post","offset":12,"onmobile":false,"dimmer":false},
    copycode: {"enable":false,"show_result":false,"style":null},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
    bookmark: {"enable":false,"color":"#222","save":"auto"},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: 'search.json',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    translation: {
      copy_button: '复制',
      copy_success: '复制成功',
      copy_failure: '复制失败'
    },
    sidebarPadding: 40
  };
</script>

  <meta name="description" content="tmux是一款优秀的终端复用软件，它比Screen更加强大。 tmux之所以受人们喜爱，主要得益于以下功能：  丝滑分屏（split），虽然iTem2也提供了横向和竖向分屏功能，但这种分屏功能非常拙劣，完全等同于屏幕新开一个窗口，新开的pane不会自动进入到当前目录，也没有记住当前登录状态。这意味着如果我ssh进入到远程服务器时，iTem2新开的pane中，我依然要重新走一遍ssh登录的老路（om">
<meta name="keywords" content="linux,tmux,iterm2">
<meta property="og:type" content="article">
<meta property="og:title" content="iterm2上tmux和oh_my_tmux的使用">
<meta property="og:url" content="https://unix2dos.github.io/p/29f1e79c.html">
<meta property="og:site_name" content="Levon&#39;s Blog">
<meta property="og:description" content="tmux是一款优秀的终端复用软件，它比Screen更加强大。 tmux之所以受人们喜爱，主要得益于以下功能：  丝滑分屏（split），虽然iTem2也提供了横向和竖向分屏功能，但这种分屏功能非常拙劣，完全等同于屏幕新开一个窗口，新开的pane不会自动进入到当前目录，也没有记住当前登录状态。这意味着如果我ssh进入到远程服务器时，iTem2新开的pane中，我依然要重新走一遍ssh登录的老路（om">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="https://unix2dos.github.io/p/29f1e79c/1.png">
<meta property="og:image" content="https://unix2dos.github.io/p/29f1e79c/2.png">
<meta property="og:updated_time" content="2019-09-27T15:36:51.159Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="iterm2上tmux和oh_my_tmux的使用">
<meta name="twitter:description" content="tmux是一款优秀的终端复用软件，它比Screen更加强大。 tmux之所以受人们喜爱，主要得益于以下功能：  丝滑分屏（split），虽然iTem2也提供了横向和竖向分屏功能，但这种分屏功能非常拙劣，完全等同于屏幕新开一个窗口，新开的pane不会自动进入到当前目录，也没有记住当前登录状态。这意味着如果我ssh进入到远程服务器时，iTem2新开的pane中，我依然要重新走一遍ssh登录的老路（om">
<meta name="twitter:image" content="https://unix2dos.github.io/p/29f1e79c/1.png">
  <link rel="canonical" href="https://unix2dos.github.io/p/29f1e79c">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true,
    isPage: false,
    isArchive: false
  };
</script>

  <title>iterm2上tmux和oh_my_tmux的使用 | Levon's Blog</title>
  








  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .logo,
  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">
  <div class="container use-motion">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-meta">

    <div>
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Levon's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
        <h1 class="site-subtitle" itemprop="description">微信:  L6241425</h1>
      
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
      
      
      
        
        <li class="menu-item menu-item-home">
      
    

    <a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-archives">
      
    

    <a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i> <br>时光</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-categories">
      
    

    <a href="/categories/" rel="section"><i class="menu-item-icon fa fa-fw fa-th"></i> <br>分类</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-tags">
      
    

    <a href="/tags/" rel="section"><i class="menu-item-icon fa fa-fw fa-tags"></i> <br>标签</a>

  </li>
      <li class="menu-item menu-item-search">
        <a href="javascript:;" class="popup-trigger">
        
          <i class="menu-item-icon fa fa-search fa-fw"></i> <br>搜索</a>
      </li>
    
  </ul>

</nav>
  <div class="site-search">
    <div class="popup search-popup">
    <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocorrect="off" autocapitalize="none"
           placeholder="搜索..." spellcheck="false"
           type="text" id="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result"></div>

</div>
<div class="search-pop-overlay"></div>

  </div>
</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
            

          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
      <article itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block post">
    <link itemprop="mainEntityOfPage" href="https://unix2dos.github.io/p/29f1e79c.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Levon">
      <meta itemprop="description" content="Never Give Up">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Levon's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">iterm2上tmux和oh_my_tmux的使用

          
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              
                
              

              <time title="创建时间：2019-07-02 08:22:46" itemprop="dateCreated datePublished" datetime="2019-07-02T08:22:46+08:00">2019-07-02</time>
            </span>
          
            

            
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2019-09-27 23:36:51" itemprop="dateModified" datetime="2019-09-27T23:36:51+08:00">2019-09-27</time>
              </span>
            
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/2-linux系统/" itemprop="url" rel="index"><span itemprop="name">2-linux系统</span></a></span>

                
                
                  ，
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/2-linux系统/iterm2/" itemprop="url" rel="index"><span itemprop="name">iterm2</span></a></span>

                
                
              
            </span>
          

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
        
      
      <span class="post-meta-item-text">Disqus：</span>
    
    <a title="disqus" href="/p/29f1e79c.html#comments" itemprop="discussionUrl"><span class="post-comments-count disqus-comment-count" data-disqus-identifier="p/29f1e79c.html" itemprop="commentCount"></span></a>
  </span>
  
  
          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
              
                <span class="post-meta-item-text">本文字数：</span>
              
              <span>3.9k</span>
            </span>
          
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
              
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              
              <span>4 分钟</span>
            </span>
          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>tmux是一款优秀的终端复用软件，它比Screen更加强大。 tmux之所以受人们喜爱，主要得益于以下功能：</p>
<ul>
<li><p>丝滑分屏（split），虽然iTem2也提供了横向和竖向分屏功能，但这种分屏功能非常拙劣，完全等同于屏幕新开一个窗口，新开的pane不会自动进入到当前目录，也没有记住当前登录状态。这意味着如果我ssh进入到远程服务器时，iTem2新开的pane中，我依然要重新走一遍ssh登录的老路（omg）。tmux就不会这样，tmux窗口中，新开的pane，默认进入到之前的路径，如果是ssh连接，登录状态也依旧保持着，如此一来，我就可以随意的增删pane，这种灵活性，好处不言而喻。</p>
</li>
<li><p>保护现场（attach），即使命令行的工作只进行到一半，关闭终端后还可以重新进入到操作现场，继续工作。对于ssh远程连接而言，即使网络不稳定也没有关系，掉线后重新连接，可以直奔现场，之前运行中的任务，依旧在跑，就好像从来没有离开过一样；特别是在远程服务器上运行耗时的任务，tmux可以帮你一直保持住会话。如此一来，你就可以随时随地放心地进行移动办公，只要你附近的计算机装有tmux（没有你也可以花几分钟装一个），你就能继续刚才的工作。</p>
</li>
</ul>
<a id="more"></a>

<ul>
<li>上下效果图</li>
</ul>
<p><img src="/p/29f1e79c/1.png" alt="1"></p>
<p><img src="/p/29f1e79c/2.png" alt="1"></p>
<h3 id="1-tmux-安装"><a href="#1-tmux-安装" class="headerlink" title="1. tmux 安装"></a>1. tmux 安装</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">brew install tmux <span class="comment">#mac</span></span><br><span class="line"></span><br><span class="line">apt-get install tmux <span class="comment">#linux</span></span><br></pre></td></tr></table></figure>

<p>安装成功后, 需要再安装一个插件:   <a href="https://github.com/gpakosz/.tmux" target="_blank" rel="noopener">https://github.com/gpakosz/.tmux</a></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span></span><br><span class="line">git <span class="built_in">clone</span> https://github.com/gpakosz/.tmux.git</span><br><span class="line">ln -s -f .tmux/.tmux.conf</span><br><span class="line">cp .tmux/.tmux.conf.local .</span><br></pre></td></tr></table></figure>

<p>以后配置修改   ~/.tmux.conf.local 即可. </p>
<h3 id="2-tmux-配置"><a href="#2-tmux-配置" class="headerlink" title="2. tmux 配置"></a>2. tmux 配置</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">tmux <span class="built_in">source</span>-file ~/.tmux.conf <span class="comment"># 刷新配置</span></span><br><span class="line"></span><br><span class="line"><span class="built_in">set</span>-option -g prefix2 `  <span class="comment"># 设置一个不常用的`键作为指令前缀，按键更快些, 建议用 ctrl+a</span></span><br><span class="line"></span><br><span class="line"><span class="built_in">set</span> -g mouse on  <span class="comment"># 最好关掉, 要不然影响iterm2自带鼠标选中</span></span><br></pre></td></tr></table></figure>

<p> Oh My Tmux 快捷键</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">自动把 ctrl + a 当做第二个前缀</span><br><span class="line"></span><br><span class="line">&lt;prefix&gt; m <span class="comment">#切换鼠标开启状态</span></span><br><span class="line"></span><br><span class="line">&lt;prefix&gt; e <span class="comment">#自动打开配置</span></span><br><span class="line"></span><br><span class="line">&lt;prefix&gt; r <span class="comment"># 刷新配置</span></span><br><span class="line"></span><br><span class="line">&lt;prefix&gt; C-c  <span class="comment">#新建一个 Session</span></span><br><span class="line"></span><br><span class="line">&lt;prefix&gt; C-h 和 &lt;prefix&gt; C<span class="_">-l</span> <span class="comment"># 向左向右切换 window</span></span><br><span class="line"></span><br><span class="line">&lt;prefix&gt; Tab <span class="comment">#回到上一个 window</span></span><br><span class="line"></span><br><span class="line">&lt;prefix&gt; - 和 &lt;prefix&gt; _  <span class="comment">#水平和垂直分屏</span></span><br><span class="line"></span><br><span class="line">&lt;prefix&gt; h, &lt;prefix&gt; j, &lt;prefix&gt; k and &lt;prefix&gt; l    <span class="comment">#移动 panel</span></span><br><span class="line"></span><br><span class="line">&lt;prefix&gt; + <span class="comment">#让当前 panel 成为 window, 注意 再一次还能回到 panel</span></span><br></pre></td></tr></table></figure>

<p>修改Oh My Tmux 配置</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line">tmux_conf_new_window_retain_current_path=<span class="literal">true</span>  <span class="comment">#window保持路径</span></span><br><span class="line">tmux_conf_new_pane_reconnect_ssh=<span class="literal">true</span>  <span class="comment">#重新连接 ssh</span></span><br><span class="line">tmux_conf_new_session_prompt=<span class="literal">true</span>  <span class="comment">#新建 session 输入名字</span></span><br><span class="line"></span><br><span class="line">tmux_conf_theme_status_left=<span class="string">' ❐ #S '</span>  <span class="comment">#左边状态栏精简</span></span><br><span class="line">tmux_conf_theme_status_right=<span class="string">'#&#123;prefix&#125;#&#123;pairing&#125;#&#123;synchronized&#125; #(curl wttr.in?format=3) | %Y-%m-%d | %H:%M:%S | w-#(echo $(((%j/7)+(%j%7&gt;0)))) , %a'</span> <span class="comment"># 右边显示天气, 和week of year</span></span><br><span class="line">tmux_conf_theme_prefix=<span class="string">'🍎 🍐 🍊 🍋 🍌 🍉 '</span>  <span class="comment"># 前缀显示emoji</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">增加配置</span><br><span class="line"></span><br><span class="line"><span class="built_in">bind</span> N previous-window <span class="comment"># 上一个窗口</span></span><br><span class="line"><span class="built_in">bind</span> n next-window <span class="comment"># 下一个窗口</span></span><br><span class="line"></span><br><span class="line"><span class="built_in">bind</span>-key -n C-S-Left swap-window -t -1 <span class="comment"># Ctrl+Shift+Left  window向左(不需要prefix)</span></span><br><span class="line"><span class="built_in">bind</span>-key -n C-S-Right swap-window -t +1 <span class="comment">#  Ctrl+Shift+Left window向右(不需要prefix)</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#bind-key x kill-pane # 关闭确认</span></span><br><span class="line"><span class="comment">#bind-key &amp; kill-window # 关闭确认</span></span><br><span class="line"></span><br><span class="line"><span class="built_in">set</span>-option -g status-position top <span class="comment"># 状态栏放到上面</span></span><br><span class="line"></span><br><span class="line"><span class="built_in">set</span> -g status-right <span class="string">'Continuum status: #&#123;continuum_status&#125;'</span></span><br><span class="line"><span class="built_in">set</span> -g @continuum-save-interval <span class="string">'10'</span></span><br><span class="line"><span class="built_in">set</span> -g @continuum-restore <span class="string">'on'</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># List of plugins</span></span><br><span class="line"><span class="built_in">set</span> -g @tpm_plugins <span class="string">'          \</span></span><br><span class="line"><span class="string">	tmux-plugins/tpm             \</span></span><br><span class="line"><span class="string">	tmux-plugins/tmux-resurrect  \</span></span><br><span class="line"><span class="string">	tmux-plugins/tmux-continuum  \</span></span><br><span class="line"><span class="string">'</span></span><br><span class="line"><span class="comment"># Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)</span></span><br><span class="line">run <span class="string">'~/.tmux/plugins/tpm/tpm'</span></span><br></pre></td></tr></table></figure>

<h3 id="3-tmux-使用"><a href="#3-tmux-使用" class="headerlink" title="3. tmux 使用"></a>3. tmux 使用</h3><p>tmux使用C/S模型构建，主要包括以下单元模块：</p>
<ul>
<li>server服务器。输入tmux命令时就开启了一个服务器。</li>
<li>session会话。一个服务器可以包含多个会话</li>
<li>window窗口。一个会话可以包含多个窗口。</li>
<li>pane面板。一个窗口可以包含多个面板。</li>
</ul>
<p>我习惯一个项目用一个 session, 一个工作区用一个 window, 快捷操作开始一个 panel. 如果刚开始记不住 tmux的操作, 一定多练习, 一定多用, 你会发现离不开它了.</p>
<h4 id="3-0-tmux-命令"><a href="#3-0-tmux-命令" class="headerlink" title="3.0 tmux 命令"></a>3.0 tmux 命令</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">tmux ls <span class="comment"># 查看当前所有的session</span></span><br><span class="line"></span><br><span class="line">tmux	<span class="comment"># 新建一个无名称的会话, 可以用$再改名</span></span><br><span class="line"></span><br><span class="line">tmux new -s demo <span class="comment"># 新建一个名称为demo的会话, </span></span><br><span class="line"></span><br><span class="line">tmux attach -t session_name <span class="comment"># 连接之前退出的session</span></span><br><span class="line"></span><br><span class="line">tmux attach-session  <span class="comment"># 快速进入 session</span></span><br><span class="line"></span><br><span class="line">tmux <span class="built_in">kill</span>-server  <span class="comment">#关闭服务器，所有的会话都将关闭</span></span><br></pre></td></tr></table></figure>

<h4 id="3-1-session操作"><a href="#3-1-session操作" class="headerlink" title="3.1 session操作"></a>3.1 session操作</h4><ul>
<li><p>新建 <prefix> C-c   或     :new </prefix></p>
</li>
<li><p>删除  :kill-session  或  tmux ls 以后 tmux kill-session -t 名字</p>
</li>
<li><p>选择 s</p>
</li>
<li><p>重命名 $</p>
</li>
<li><p>退出  d</p>
</li>
</ul>
<h4 id="3-2-window-操作"><a href="#3-2-window-操作" class="headerlink" title="3.2 window 操作"></a>3.2 window 操作</h4><ul>
<li><p>新建   c</p>
</li>
<li><p>关闭  ctrl+d 或   &amp;</p>
</li>
<li><p>列表  w   可切到其他 session</p>
</li>
<li><p>重命名  ,</p>
</li>
<li><p>跳跃  0-9</p>
</li>
<li><p>向左 C-h  或   n</p>
</li>
<li><p>向右 C-l  或   p</p>
</li>
</ul>
<h4 id="3-3-panel-操作"><a href="#3-3-panel-操作" class="headerlink" title="3.3 panel 操作"></a>3.3 panel 操作</h4><ul>
<li><p>新建上下   - 或  “</p>
</li>
<li><p>新建左右   _  或 %</p>
</li>
<li><p>关闭  ctrl+d  或 x</p>
</li>
<li><p>切换： 空格键</p>
</li>
<li><p>移动    hjkl 键 或 上下左右键</p>
</li>
<li><p>最大化  z</p>
</li>
<li><p>变窗口  !   如果只是临时变 window, 用+</p>
</li>
</ul>
<h3 id="4-tmux-遇到的问题"><a href="#4-tmux-遇到的问题" class="headerlink" title="4. tmux 遇到的问题"></a>4. tmux 遇到的问题</h3><ol>
<li><p>off, 鼠标无法滚动</p>
<p>In iTerm2 all you need to do is to go to Preferences &gt; Profile &gt; Terminal and check ‘Save lines to scrollback when an app status bar is present’.</p>
</li>
<li><p>on, 鼠标无法智能选中</p>
<p>快速关闭, m</p>
</li>
<li><p>无论off, on  鼠标点击文件不是默认 app 打开</p>
<p><a href="https://stackoverflow.com/a/56715244/7062454" target="_blank" rel="noopener">https://stackoverflow.com/a/56715244/7062454</a></p>
<p>自己强答一题: 先退出 tmux seesion, 用鼠标点击通过默认 app 打开, 再进入 tmux session 就可以了</p>
</li>
</ol>
<h3 id="5-tmux-插件"><a href="#5-tmux-插件" class="headerlink" title="5. tmux 插件"></a>5. tmux 插件</h3><ul>
<li>tpm</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git <span class="built_in">clone</span> https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm</span><br></pre></td></tr></table></figure>

<ul>
<li>tmux-resurrect</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">&lt;prefix&gt; ctrl + s <span class="comment">#save</span></span><br><span class="line">&lt;prefix&gt; ctrl + r <span class="comment">#load</span></span><br></pre></td></tr></table></figure>

<h3 id="6-参考资料"><a href="#6-参考资料" class="headerlink" title="6. 参考资料"></a>6. 参考资料</h3><p>进阶: <a href="http://louiszhai.github.io/2017/09/30/tmux/" target="_blank" rel="noopener">http://louiszhai.github.io/2017/09/30/tmux/</a></p>

    </div>

    
    
    
        
      
        <div id="reward-container">
  <div>坚持原创技术分享，您的支持将鼓励我继续创作, 一个耿直的笑脸~</div>
  <button id="reward-button" disable="enable" onclick="var qr = document.getElementById(&quot;qr&quot;); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">
        
      
      <div style="display: inline-block">
        <img src="/images/wechatpay.jpg" alt="Levon 微信支付">
        <p>微信支付</p>
      </div>
        
      
      <div style="display: inline-block">
        <img src="/images/alipay.jpg" alt="Levon 支付宝">
        <p>支付宝</p>
      </div>

  </div>
</div>

      

      <footer class="post-footer">
          
            
          
          <div class="post-tags">
            
              <a href="/tags/linux/" rel="tag"># linux</a>
            
              <a href="/tags/tmux/" rel="tag"># tmux</a>
            
              <a href="/tags/iterm2/" rel="tag"># iterm2</a>
            
          </div>
        

        

          <div class="post-nav">
            <div class="post-nav-next post-nav-item">
              
                <a href="/p/c1403091.html" rel="next" title="/etc/systemd/system和/lib/systemd/system的区别">
                  <i class="fa fa-chevron-left"></i> /etc/systemd/system和/lib/systemd/system的区别
                </a>
              
            </div>

            <span class="post-nav-divider"></span>

            <div class="post-nav-prev post-nav-item">
              
                <a href="/p/6600d67c.html" rel="prev" title="iterm2_zsh配置">
                  iterm2_zsh配置 <i class="fa fa-chevron-right"></i>
                </a>
              
            </div>
          </div>
        
      </footer>
    
  </div>
  
  
  
  </article>

  </div>


          </div>
          
    
    
  <div class="comments" id="comments">
    <div id="disqus_thread">
      <noscript>Please enable JavaScript to view the comments powered by Disqus.</noscript>
    </div>
  </div>
  
  

        </div>
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">
        
        
        
        
      

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-tmux-安装"><span class="nav-number">1.</span> <span class="nav-text">1. tmux 安装</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-tmux-配置"><span class="nav-number">2.</span> <span class="nav-text">2. tmux 配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-tmux-使用"><span class="nav-number">3.</span> <span class="nav-text">3. tmux 使用</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#3-0-tmux-命令"><span class="nav-number">3.1.</span> <span class="nav-text">3.0 tmux 命令</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-1-session操作"><span class="nav-number">3.2.</span> <span class="nav-text">3.1 session操作</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-2-window-操作"><span class="nav-number">3.3.</span> <span class="nav-text">3.2 window 操作</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-3-panel-操作"><span class="nav-number">3.4.</span> <span class="nav-text">3.3 panel 操作</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-tmux-遇到的问题"><span class="nav-number">4.</span> <span class="nav-text">4. tmux 遇到的问题</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5-tmux-插件"><span class="nav-number">5.</span> <span class="nav-text">5. tmux 插件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-参考资料"><span class="nav-number">6.</span> <span class="nav-text">6. 参考资料</span></a></li></ol></div>
        
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image"
      src="/images/avatar.jpg"
      alt="Levon">
  <p class="site-author-name" itemprop="name">Levon</p>
  <div class="site-description" itemprop="description">Never Give Up</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        
          <a href="/archives/">
        
          <span class="site-state-item-count">127</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-categories">
        
          
            <a href="/categories/">
          
        
        <span class="site-state-item-count">34</span>
        <span class="site-state-item-name">分类</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-tags">
        
          
            <a href="/tags/">
          
        
        <span class="site-state-item-count">76</span>
        <span class="site-state-item-name">标签</span>
        </a>
      </div>
    
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://github.com/unix2dos" title="GitHub &rarr; https://github.com/unix2dos" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="mailto:levonfly@gmail.com" title="E-Mail &rarr; mailto:levonfly@gmail.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://twitter.com/levonfly" title="Twitter &rarr; https://twitter.com/levonfly" rel="noopener" target="_blank"><i class="fa fa-fw fa-twitter"></i>Twitter</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://weibo.com/l6241425" title="Weibo &rarr; https://weibo.com/l6241425" rel="noopener" target="_blank"><i class="fa fa-fw fa-weibo"></i>Weibo</a>
      </span>
    
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Levon</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    <span title="站点总字数">507k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">7:41</span>
</div>

        












        
      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js?v=3.1.0"></script>
  <script src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  <script src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
<script src="/js/utils.js?v=7.4.0"></script><script src="/js/motion.js?v=7.4.0"></script>
<script src="/js/schemes/pisces.js?v=7.4.0"></script>

<script src="/js/next-boot.js?v=7.4.0"></script>



  
  <script>
    (function(){
      var bp = document.createElement('script');
      var curProtocol = window.location.protocol.split(':')[0];
      bp.src = (curProtocol === 'https') ? 'https://zz.bdstatic.com/linksubmit/push.js' : 'http://push.zhanzhang.baidu.com/push.js';
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(bp, s);
    })();
  </script>








  <script src="/js/local-search.js?v=7.4.0"></script>














  

  

  

<script>
  function loadCount() {
    var d = document, s = d.createElement('script');
    s.src = 'https://levonfly.disqus.com/count.js';
    s.id = 'dsq-count-scr';
    (d.head || d.body).appendChild(s);
  }
  // defer loading until the whole page loading is completed
  window.addEventListener('load', loadCount, false);
</script>
<script>
  function disqus_config() {
    this.page.url = "https://unix2dos.github.io/p/29f1e79c.html";
    this.page.identifier = "p/29f1e79c.html";
    this.page.title = 'iterm2上tmux和oh_my_tmux的使用';};
  function loadComments() {
    if (window.DISQUS) {
      DISQUS.reset({
        reload: true,
        config: disqus_config
      });
    } else {
      var d = document, s = d.createElement('script');
      s.src = 'https://levonfly.disqus.com/embed.js';
      s.setAttribute('data-timestamp', '' + +new Date());
      (d.head || d.body).appendChild(s);
    }
  }
    window.addEventListener('load', loadComments, false);
  
</script>

</body>
</html>
